﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinCourseControls.UControls
{
    /// <summary>
    /// 组合控件
    /// </summary>
    [DefaultEvent("EditTextChanged")]  // 设置事件为默认事件
    public partial class EditTextBox : UserControl
    {

        public EditTextBox()
        {
            InitializeComponent();
             
        }
        /// <summary>
        /// 描述文本-设置标签文本属性
        /// </summary>
        public string LabelText
        {
            get { return lblInfo.Text; }
            set
            {
                lblInfo.Text = value;
            }
        }

        /// <summary>
        /// 编辑框的文本
        /// </summary>
        public string EditText
        { 
            get { return txtValue.Text; }
            set
            {
                txtValue.Text = value;
            }
        }
        /// <summary>
        /// 文本编辑框是否为多行
        /// </summary>
        public bool MultiLine
        {
            get {return txtValue.Multiline; }
            set { txtValue.Multiline = value; }
        }

        /// <summary>
        /// 描述文本的文字颜色
        /// </summary>
        public Color LabelFColor
        {
            get { return lblInfo.ForeColor; }
            set
            {
                lblInfo.ForeColor = value;
            }
        }

        /// <summary>
        /// 描述文本的文字颜色
        /// </summary>
        public Color EditTextFColor
        {
            get { return txtValue.ForeColor; }
            set
            {
                txtValue.ForeColor = value;
            }
        }
        /// <summary>
        /// 编辑值改时事件
        /// </summary>
        public event EventHandler EditTextChanged;

        /// <summary>
        /// 文本框值改变事件的引发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtValue_TextChanged(object sender, EventArgs e)
        {
            EditTextChanged?.Invoke(this, new EventArgs());  // 委托执行事件
        }
    }
}
